package com.yoda.youdianda.controller;

import com.yoda.youdianda.common.R;
import com.yoda.youdianda.domain.YddLink;
import com.yoda.youdianda.service.YddLinkService;
import com.yoda.youdianda.vo.PageResult;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("ydd_link")
@AllArgsConstructor
public class YddLinkController {
    private YddLinkService yddLinkService;

    //链接详情
    @GetMapping("rowInfo")
    public R rowInfo(Integer id) {
        YddLink yddLink = yddLinkService.rowInfo(id);
        return R.success(yddLink);
    }

    //链接修改
    @PostMapping("update")
    public R updateYddLink(@RequestBody YddLink yddLink) {
        yddLinkService.updateYddLink(yddLink);
        return R.success("修改成功");
    }

    //链接删除
    @GetMapping("del")
    public R deleteById(Integer id) {
        yddLinkService.deleteById(id);
        return R.success("删除成功");
    }

    //链接添加
    @PostMapping("add")
    public R addYddLink(@RequestBody YddLink yddLink) {
        yddLinkService.addYddLink(yddLink);
        return R.success("添加成功");
    }

    //链接列表
    @GetMapping("list")
    public R list(String type, Integer page, Integer limit) {
        PageResult pageResult = yddLinkService.selectYddLinkList(type, page, limit);
        return R.success(pageResult);
    }
}
